home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / arvis1 / soundmod.bas < prev    next >
BASIC Source File  |  1999-08-13  |  2KB  |  48 lines

  1. Attribute VB_Name = "SoundMod"
  2. '»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»'
  3. ' This Sub Hold Sound Functions, Api's and Variables '
  4. '____________________________________________________'
  5. ' api for midi
  6. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
  7. ' api for wave
  8. Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
  9. ' wave consts
  10. Private Const SND_SYNC = &H0
  11. Private Const SND_ASYNC = &H1
  12. Private Const SND_NODEFAULT = &H2
  13. Private Const SND_MEMORY = &H4
  14. Private Const SND_LOOP = &H8
  15. Private Const SND_NOSTOP = &H10
  16. ' loop a wave
  17. Sub WAVLoop(File As String)
  18. On Error Resume Next
  19.    ThisDir
  20.    wFlags% = SND_ASYNC Or SND_LOOP
  21.    X = sndPlaySound(File, wFlags%)
  22. End Sub
  23. ' play a wave once
  24. Sub WAVPlay(File As String)
  25. On Error Resume Next
  26.     ThisDir
  27.     wFlags% = SND_ASYNC Or SND_NODEFAULT
  28.     X = sndPlaySound(" ", wFlags%)
  29.     X = sndPlaySound(File, wFlags%)
  30. End Sub
  31. ' play midi, no loop yet
  32. Sub MidiPlay(File As String)
  33.  On Error Resume Next
  34.  ChDrive App.Path
  35.  ChDir App.Path
  36.  MIDIPath$ = File
  37.  X& = mciSendString("open " & MIDIPath & " Type sequencer Alias MFile", 0&, 0, 0)
  38.  X& = mciSendString("play MFile", 0&, 0, 0)
  39. End Sub
  40. Public Sub StopSounds(Optional Wav As Boolean, Optional Midi As Boolean)
  41.  On Error Resume Next
  42. If Wav = True Then Call WAVPlay(" ")
  43. If Midi = True Then
  44.  X& = mciSendString("stop MFile", 0&, 0, 0)
  45.  X& = mciSendString("close MFile", 0&, 0, 0)
  46. End If
  47. End Sub
  48.